package com.mind.adjust.service.impl;

import com.mind.system.domain.AjAttachCateRuleField;
import com.mind.adjust.mapper.AjAttachCateRuleFieldMapper;
import com.mind.adjust.service.AjAttachCateRuleFieldService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 附件类型规则字段(AjAttachCateRuleField)表服务实现类
 *
 * @author makejava
 * @since 2024-07-11 17:55:41
 */
@Service("attachCateRuleFieldService")
public class AjAttachCateRuleFieldServiceImpl implements AjAttachCateRuleFieldService {
    @Autowired
    private AjAttachCateRuleFieldMapper attachCateRuleFieldMapper;

    /**
     * 查询附件类型规则字段信息集合
     * 
     * @param attachCateRuleField 附件类型规则字段信息
     * @return 附件类型规则字段信息集合
     */
    @Override
    public List<AjAttachCateRuleField> selectAttachCateRuleFieldList(AjAttachCateRuleField attachCateRuleField)
    {
        return attachCateRuleFieldMapper.selectAttachCateRuleFieldList(attachCateRuleField);
    }

    /**
     * 通过附件类型规则字段ID查询附件类型规则字段信息
     * 
     * @param attachCateRuleFieldId 附件类型规则字段ID
     * @return 角色对象信息
     */
    @Override
    public AjAttachCateRuleField selectAttachCateRuleFieldById(Long attachCateRuleFieldId)
    {
        return attachCateRuleFieldMapper.selectAttachCateRuleFieldById(attachCateRuleFieldId);
    }

    /**
     * 删除附件类型规则字段信息
     * 
     * @param attachCateRuleFieldId 附件类型规则字段ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateRuleFieldById(Long attachCateRuleFieldId)
    {
        return attachCateRuleFieldMapper.deleteAttachCateRuleFieldById(attachCateRuleFieldId);
    }

    /**
     * 批量删除附件类型规则字段信息
     * 
     * @param attachCateRuleFieldIds 需要删除的附件类型规则字段ID
     * @return 结果
     */
    @Override
    public int deleteAttachCateRuleFieldByIds(Long[] attachCateRuleFieldIds)
    {
        return attachCateRuleFieldMapper.deleteAttachCateRuleFieldByIds(attachCateRuleFieldIds);
    }

    /**
     * 新增保存附件类型规则字段信息
     * 
     * @param attachCateRuleField 附件类型规则字段信息
     * @return 结果
     */
    @Override
    public int insertAttachCateRuleField(AjAttachCateRuleField attachCateRuleField)
    {
        return attachCateRuleFieldMapper.insertAttachCateRuleField(attachCateRuleField);
    }

    /**
     * 修改保存附件类型规则字段信息
     * 
     * @param attachCateRuleField 附件类型规则字段信息
     * @return 结果
     */
    @Override
    public int updateAttachCateRuleField(AjAttachCateRuleField attachCateRuleField)
    {
        return attachCateRuleFieldMapper.updateAttachCateRuleField(attachCateRuleField);
    }
    
    /**
     * 批量插入
     *
     * @param attachCateRuleFieldList 附件类型信息
     * @return 结果
     */
    @Override
    public int batchInsert(List<AjAttachCateRuleField> attachCateRuleFieldList) {
        int size = 0;
        for(AjAttachCateRuleField attachCateRuleField: attachCateRuleFieldList) {
            if (attachCateRuleFieldMapper.selectAttachCateRuleFieldByName(attachCateRuleField.getName()) == null){
                attachCateRuleFieldMapper.insertAttachCateRuleField(attachCateRuleField);
                size ++;
            }
        }
        return size;
    }
}
